gint width,
gint height);
+GdkGLContext *gdk_surface_get_shared_data_gl_context (GdkSurface *surface);
+
G_END_DECLS
#endif /* __GDK_INTERNALS_H__ */
return surface->state;
}
+GdkGLContext *
+gdk_surface_get_shared_data_gl_context (GdkSurface *surface)
+{
+ static int in_shared_data_creation;
+ GdkDisplay *display;
+ GdkGLContext *context;
+
+ if (in_shared_data_creation)
+ return NULL;
+
+ in_shared_data_creation = 1;
+
+ display = gdk_surface_get_display (surface);
+ context = (GdkGLContext *)g_object_get_data (G_OBJECT (display), "gdk-gl-shared-data-context");
+ if (context == NULL)
+ {
+ GError *error = NULL;
+ context = GDK_SURFACE_GET_CLASS (surface)->create_gl_context (surface, FALSE, NULL, &error);
+ if (context == NULL)
+ {
+ g_warning ("Failed to create shared context: %s", error->message);
+ g_clear_error (&error);
+ }
+
+ gdk_gl_context_realize (context, &error);
+ if (context == NULL)
+ {
+ g_warning ("Failed to realize shared context: %s", error->message);
+ g_clear_error (&error);
+ }
+
+
+ g_object_set_data (G_OBJECT (display), "gdk-gl-shared-data-context", context);
+ }
+
+ in_shared_data_creation = 0;
+
+ return context;
+}
+
GdkGLContext *
gdk_surface_get_paint_gl_context (GdkSurface *surface,
GError **error)
GdkWaylandGLContext *context_wayland = GDK_WAYLAND_GL_CONTEXT (context);
GdkDisplay *display = gdk_gl_context_get_display (context);
GdkGLContext *share = gdk_gl_context_get_shared_context (context);
+ GdkGLContext *shared_data_context = gdk_surface_get_shared_data_gl_context (gdk_gl_context_get_surface (context));
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
EGLContext ctx;
EGLint context_attribs[N_EGL_ATTRS];
ctx = eglCreateContext (display_wayland->egl_display,
context_wayland->egl_config,
share != NULL ? GDK_WAYLAND_GL_CONTEXT (share)->egl_context
- : EGL_NO_CONTEXT,
+ : shared_data_context != NULL ? GDK_WAYLAND_GL_CONTEXT (shared_data_context)->egl_context
+ : EGL_NO_CONTEXT,
context_attribs);
/* If context creation failed without the legacy bit, let's try again with it */
ctx = eglCreateContext (display_wayland->egl_display,
context_wayland->egl_config,
share != NULL ? GDK_WAYLAND_GL_CONTEXT (share)->egl_context
- : EGL_NO_CONTEXT,
+ : shared_data_context != NULL ? GDK_WAYLAND_GL_CONTEXT (shared_data_context)->egl_context
+ : EGL_NO_CONTEXT,
context_attribs);
}
Display *dpy;
DrawableInfo *info;
GdkGLContext *share;
+ GdkGLContext *shared_data_context;
GdkSurface *surface;
gboolean debug_bit, compat_bit, legacy_bit, es_bit;
int major, minor, flags;
context_x11 = GDK_X11_GL_CONTEXT (context);
display_x11 = GDK_X11_DISPLAY (display);
share = gdk_gl_context_get_shared_context (context);
+ shared_data_context = gdk_surface_get_shared_data_gl_context (surface);
gdk_gl_context_get_required_version (context, &major, &minor);
debug_bit = gdk_gl_context_get_debug_enabled (context);
if (legacy_bit && !GDK_X11_DISPLAY (display)->has_glx_create_context)
{
GDK_DISPLAY_NOTE (display, OPENGL, g_message ("Creating legacy GL context on request"));
- context_x11->glx_context = create_legacy_context (display, context_x11->glx_config, share);
+ context_x11->glx_context = create_legacy_context (display, context_x11->glx_config, share ? share : shared_data_context);
}
else
{
GDK_DISPLAY_NOTE (display, OPENGL, g_message ("Creating GL3 context"));
context_x11->glx_context = create_gl3_context (display,
context_x11->glx_config,
- share,
+ share ? share : shared_data_context,
profile, flags, major, minor);
/* Fall back to legacy in case the GL3 context creation failed */
if (context_x11->glx_context == NULL)
{
GDK_DISPLAY_NOTE (display, OPENGL, g_message ("Creating fallback legacy context"));
- context_x11->glx_context = create_legacy_context (display, context_x11->glx_config, share);
+ context_x11->glx_context = create_legacy_context (display, context_x11->glx_config, share ? share : shared_data_context);
legacy_bit = TRUE;
es_bit = FALSE;
}